<template>
	<view class="content">
		<u-navbar :title="title1" :autoBack="false" leftIcon=" " placeholder></u-navbar>
		<u-loading-page :loading="loading" loading-text="微信初始化中..."></u-loading-page>
	</view>
</template>

<script>
	import user from '@/api/_user.js'
	export default {
		data() {
			return {
				loading:true
			}
		},
		
		onLoad() {
			let _this=this
			uni.login({
			  provider: 'weixin', //使用微信登录
			  success: function (loginRes) {
					user.getopenid({code:loginRes.code}).then(res=>{
						if(res.data.code==1){
							user.wxLogin({openId:res.data.data.openid}).then(res1=>{
								uni.setStorageSync('xgtoken',res1.data.data.userinfo.token)
								uni.setStorageSync('xguserinfo',res1.data.data.userinfo)
								_this.loading=false
								if(res1.data.data.userinfo.school_id){
									uni.switchTab({
										url:'/pages/tabbar/home'
									})
								}else{
									uni.reLaunch({
										url:'/pages/my/checkschool'
									})
								}
							})
						}
					})
			  }
			});
		},
		methods: {

		}
	}
</script>

<style>
	page{
		background-color: transparent;
	}
</style>
